package com.example.books.Controller;

import com.example.books.Pojo.BorrowDO;
import com.example.books.Service.BorrowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
public class BorrowController {

    @Autowired
    private BorrowService borrowService;


    @PostMapping("/getBorrow")
    public List<BorrowDO> getBorrow(){
        return borrowService.getBorrows();
    }

    @PostMapping("/setBorrow")
    public boolean setBorrow(@RequestBody Map<String,Object> map){
        System.out.println(map);
        return borrowService.setBorrows(map);
    }

    @PostMapping("/UpdateBorrow")
    public boolean UpdateBorrow(@RequestBody Map<String,Object> map){
        return borrowService.updateBorrows(map);
    }

    @PostMapping("/DeleteBorrow")
    public boolean DeleteBorrow(@RequestBody Map<String,Object> map){
        System.out.println(map);
        return borrowService.deleteBorrows(map);
    }

    @PostMapping("/getBook")
    public List<BorrowDO> getBook(@RequestBody Map<String,Object> map){
        return borrowService.getBook(map);
    }

    @PostMapping("/updateback")
    public boolean updateback(@RequestBody Map<String,Object> map){
        System.out.println(map);
        return borrowService.update(map);
    }

}
